import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from "@dfeidao/atom-web/ui/set-node-cls";

import set from '@dfeidao/atom-web/local/set';

import nodejs from '@dfeidao/atom-web/msg/nodejs';

import p001 from './p001';
import p003 from './p003';
import p004 from './p004';

export default async function a005(fd: IFeidaoAiBrowserComponent, id: string) {
	// // todo
	console.log("MMMMMMM222MM=>", id);

	const pn = fd.data.params['page-no'] as string;
	let pno = 1;
	if (pn) {
		pno = parseInt(pn, 10);
	}


	console.log(pno);

	const res = await nodejs<{ res: Array<{}>; c: number; }>('risk_point/zj-000003/s003', {
		_id: id,
		page_no: 1
	});


	console.info("再次显示", res);


	//再次渲染

	const p3 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p003"]');
	set_node_cls(p3, 'display-n', false);

	// 隐藏空页面
	const d = fd.data.node.querySelector<HTMLDListElement>('[data-name="kong"]');
	d.setAttribute('class', 'display-n');

	const zong = [];
	for (let i = 0; i < res.res.length; i++) {
		const element = res.res[i] as { hidden_name: string, hidden_source: string };
		const name = element.hidden_name;
		const no = element.hidden_source;
		zong[i] = [name, no];
		// zno[i] = no;
		console.log("有无参数", name);
		console.log("有无参数132132", no);

	}
	console.log("有吗有吗", zong);

	set(fd, 'zname', zong);





	console.log("长度===》", res.res.length);

	if (res.res) {
		render(fd, res.res, p003, 'p003', 'inner');
		render(fd, { page_no: 1, total: res.c }, p004, 'p004', 'inner');
	} else {
		render(fd, '', p001, 'p001', 'inner');
	}

}
